home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #3 / Amiga Plus CD - 2002 - No. 03.iso / AmiSoft / Util / Misc / Lottery2002.lha / Lottery2002 / Source / main.c < prev   
C/C++ Source or Header  |  2003-02-09  |  3KB  |  100 lines

  1. /* main.c */
  2.  
  3. #include "includes.h"
  4.  
  5. /* Library Bases */
  6. struct Library *WindowBase     = NULL;
  7. struct Library *LayoutBase     = NULL;
  8. struct Library *LabelBase      = NULL;
  9. struct Library *ButtonBase     = NULL;
  10. struct Library *FuelGaugeBase  = NULL;
  11. struct Library *TranslatorBase = NULL;
  12.  
  13. /* Global structures & Variables */
  14. struct Menu        *g_menustrip;
  15. struct Requester   myreq;
  16. struct MsgPort     *speakMP;
  17. struct narrator_rb *speakIO;
  18.  
  19. int   seed;
  20. char  g_button[]   = "Quit Program";
  21. char  g_okbutton[] = "OK";
  22. char  g_title[]    = "Resource Allocation Failure";
  23. char  g_scrtitle[] = "Lottery2002(OS3.5/9) V2.1 © T.Collier 2002";
  24.  
  25. char *VERSION = "\0$VER: Lottery2002 2.1 (08.03.02) T.Collier";
  26.  
  27. enum
  28. {
  29.     GAD_FIRST=0,
  30.         GAD_BOX1, GAD_BOX2, GAD_BOX3,    GAD_BOX4,  GAD_BOX5,  GAD_BOX6,
  31.         GAD_BOX7, GAD_BOX8, GAD_BOX9, GAD_BOX10, GAD_BOX11, GAD_BOX12,
  32.         GAD_FUEL, GAD_START, GAD_SPEAK, GAD_QUIT,
  33.     GAD_LAST
  34. };
  35.  
  36. int wednums[6], satnums[6];
  37. BOOL spk_flag  = FALSE;
  38. BPTR filelock  = NULL;
  39.  
  40. /* Starts from here if called from WorkBench */
  41. #ifdef __STORM__  // Storm Compiler
  42. void wbmain(struct WBStartup *wbs)
  43. {
  44.          main( 0, NULL);
  45. }
  46. #endif
  47.  
  48.  
  49. void main(int argc, char *argv[])
  50. {
  51.  
  52.     /* make sure our classes opened, exit if not */
  53.     if(!(ButtonBase = (struct Library *)OpenLibrary("gadgets/button.gadget",44)))
  54.         cleanexit(requester(g_title,
  55.                            "\nCould NOT OPEN button.image V44.\n", g_button));
  56.     if(!(FuelGaugeBase = (struct Library *)OpenLibrary("gadgets/fuelgauge.gadget",44)))
  57.         cleanexit(requester(g_title,
  58.                            "\nCould NOT OPEN fuelgauge.image V44.\n", g_button));
  59.  
  60.     if(!(WindowBase = (struct Library *)OpenLibrary("window.class",44)))
  61.         cleanexit(requester(g_title,
  62.                            "\nCould NOT OPEN window.class V44.\n", g_button));
  63.  
  64.     if(!(LayoutBase = (struct Library *)OpenLibrary("gadgets/layout.gadget",44)))
  65.         cleanexit(requester(g_title,
  66.                            "\nCould NOT OPEN layout.gadget V44.\n", g_button));
  67.  
  68.     if(!(LabelBase    = (struct Library *)OpenLibrary("images/label.image",44)))
  69.         cleanexit(requester(g_title,
  70.                            "\nCould NOT OPEN label.image V44.\n", g_button));
  71.  
  72.     if(TranslatorBase = OpenLibrary("translator.library", 36L))
  73.     {
  74.         BPTR filelock = NULL;
  75.  
  76.         if((filelock) = Lock("Devs:narrator.device", ACCESS_READ))
  77.         {
  78.             spk_flag = TRUE;
  79.             UnLock(filelock);
  80.         }
  81.     }
  82.     seed = (int)time(NULL);  // use time function to set the random seed
  83.     srand(seed);
  84.  
  85.     opengui();
  86.     cleanexit(0);
  87. }
  88.  
  89. /* Close the classes */
  90. void cleanexit(int returnvalue)
  91. {
  92.     if(ButtonBase)        CloseLibrary(ButtonBase);
  93.     if(FuelGaugeBase)  CloseLibrary(FuelGaugeBase);
  94.     if(LabelBase)        CloseLibrary(LabelBase);
  95.     if(LayoutBase)        CloseLibrary(LayoutBase);
  96.     if(WindowBase)        CloseLibrary(WindowBase);
  97.     if(TranslatorBase) CloseLibrary(TranslatorBase);
  98.     exit(returnvalue);
  99. }
  100.